﻿using System.Diagnostics.Contracts;

namespace System.Reactive
{
	public static class Notification
	{
		public static Notification<T> CreateOnCompleted<T>()
		{
			Contract.Ensures(Contract.Result<Notification<T>>() != null, null, "Notification<T>>() != null");
			Contract.Ensures(Contract.Result<Notification<T>>().HasValue == false, null, "Notification<T>>().HasValue == false");
			Contract.Ensures(object.ReferenceEquals(Contract.Result<Notification<T>>().Exception, null), null, "object.ReferenceEquals(Contract.Result<Notification<T>>().Exception, null)");
			Contract.Ensures(Contract.Result<Notification<T>>().Kind == NotificationKind.OnCompleted, null, "Notification<T>>().Kind == NotificationKind.OnCompleted");
			return null;
		}

		public static Notification<T> CreateOnError<T>(Exception error)
		{
			Contract.Requires(error != null, null, "error != null");
			Contract.Ensures(Contract.Result<Notification<T>>() != null, null, "Notification<T>>() != null");
			Contract.Ensures(Contract.Result<Notification<T>>().HasValue == false, null, "Notification<T>>().HasValue == false");
			Contract.Ensures(object.ReferenceEquals(Contract.Result<Notification<T>>().Exception, error), null, "object.ReferenceEquals(Contract.Result<Notification<T>>().Exception, error)");
			Contract.Ensures(Contract.Result<Notification<T>>().Kind == NotificationKind.OnError, null, "Notification<T>>().Kind == NotificationKind.OnError");
			return null;
		}

		public static Notification<T> CreateOnNext<T>(T value)
		{
			Contract.Ensures(Contract.Result<Notification<T>>() != null, null, "Notification<T>>() != null");
			Contract.Ensures(Contract.Result<Notification<T>>().HasValue == true, null, "Notification<T>>().HasValue == true");
			Contract.Ensures(object.ReferenceEquals(Contract.Result<Notification<T>>().Exception, null), null, "object.ReferenceEquals(Contract.Result<Notification<T>>().Exception, null)");
			Contract.Ensures(Contract.Result<Notification<T>>().Kind == NotificationKind.OnNext, null, "Notification<T>>().Kind == NotificationKind.OnNext");
			return null;
		}
	}
}